//
//  StatusIndicator_Base.swift
//  TestScroll
//
//  Created by kkkelicheng on 2021/12/6.
//

import UIKit

class StatusIndicator_Base: UIView , StatusActionRequired {
    var statusAction : (()->Void)?
    
    lazy var statusImageView: UIImageView = {
        let iv = UIImageView.init(frame: .zero)
        iv.isUserInteractionEnabled = true
        iv.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imageTap)))
        return iv
    }()
    
    lazy var statusLabel: UILabel = {
        let l = UILabel.init(frame: .zero)
        l.text = ""
        l.textColor = .lightGray
        l.font = UIFont.systemFont(ofSize: 13)
        return l
    }()
    
    lazy var stk_v: UIStackView = {
        let s = UIStackView.init(frame: .zero)
        s.alignment = .center
        s.spacing = 4
        s.distribution = .fill
        s.axis = .vertical
        return s
    }()
    
    init(){
        super.init(frame: .zero)
        backgroundColor = .white
        configSubviews()
    }
    
    func configSubviews() {
        addSubview(stk_v)
        stk_v.translatesAutoresizingMaskIntoConstraints = false
        stk_v.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
        stk_v.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
        stk_v.addArrangedSubview(statusImageView)
        stk_v.addArrangedSubview(statusLabel)
    }
    
    @objc func imageTap(){
        statusAction?()
    }
        
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
